<html>
	<head>
		<meta charset="UTF-8" />
<title>运行代码</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.css">
<style>
      .codemirror-container,iframe ,textarea{
        width: 75%;
        height: 22%;
        resize: both;
        overflow: auto;
        border: 2px solid black;
        box-sizing: border-box;
      }

      .CodeMirror {
        width: 100%;
        height: 100%;
        font-size: 20px;
      }
textarea{
font-size: 20px;
}
    </style>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/addon/edit/matchbrackets.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/javascript/javascript.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/css/css.min.js"></script>
<script src="https://cdn.staticfile.org/codemirror/5.62.0/mode/htmlmixed/htmlmixed.min.js"></script>
<script src="https://cdn.staticfile.org/codemirror/5.62.0/mode/javascript/javascript.min.js"></script>
<script src="https://cdn.staticfile.org/codemirror/5.62.0/mode/xml/xml.min.js"></script>
<script src="https://cdn.staticfile.org/codemirror/5.62.0/mode/css/css.min.js"></script>
      <script src="https://fastly.jsdelivr.net/npm/esprima@4.0.1/dist/esprima.min.js"></script>
    <script>
      window.exports = {};
    </script>
    <script src="https://fastly.jsdelivr.net/npm/estraverse@5.3.0/estraverse.min.js"></script>
<script> 
estraverse = {}
estraverse.traverse = exports['traverse'];
window.exports = undefined;
</script>
</head>
<body onload='var savedErudaPosition="";if(localStorage["eruda-entry-button"]){savedErudaPosition=localStorage["eruda-entry-button"]}localStorage.clear();localStorage["eruda-entry-button"]=savedErudaPosition'>
<div id=codemirror_textarea>
<div style=float:left>HTML</div><br>
  <div class="codemirror-container">
      <textarea id="html"></textarea>
    </div><br>
<div style=float:left >JavaScript</div><br>
  <div class="codemirror-container">
      <textarea id="js"></textarea>
    </div><br>
<div style=float:left>CSS</div><br>
  <div class="codemirror-container">
      <textarea id="css"></textarea>
    </div>
</div>
<div id=original_textarea style=display:none>
<div style=float:left>HTML</div><br>
      <textarea id="html1" oninput=run1()></textarea>
<br>
<div style=float:left >JavaScript</div><br>
      <textarea id="js1" oninput=run1()></textarea>
<br>
<div style=float:left>CSS</div><br>
      <textarea id="css1" oninput=run1()></textarea>
</div>
<br>
<button onclick=run() id=run>运行代码</button>&nbsp;&nbsp;<label for=cb_time>自动执行</label><input type=checkbox checked=checked onclick=i() id=cb_time><div id=time style=display:inline-block>&nbsp;&nbsp;防抖:<input id=time_input value=500 type=number>ms</div>&nbsp;&nbsp;<label for=cb_circle>死循环保护</label><input type=checkbox id=cb_circle checked=checked>
&nbsp;&nbsp;<label for=cb_codemirror>codemirror</label><input type=checkbox id=cb_codemirror checked=checked onclick=cm_click()>&nbsp;&nbsp;<button onclick=dom("result").srcdoc="";dom("log0").srcdoc="";>紧急停止运行</button>
<br>
<div style=float:left>运行结果:</div><br><br>
<iframe id=result name=result></iframe>
<br>
<div style=float:left>console日志:</div><br><br>
<iframe id=log0 ></iframe>
<script>
//自定义函数dom
function dom(x)
{
var dom=document.getElementById(x)
return dom
}
window.onbeforeunload = function(event) {
 event.returnValue = "退出代码将不会保存，是否继续";
};
//window.onload = initializeEditors;
var html_editor=CodeMirror.fromTextArea(dom('html'), {
        lineNumbers: true,
        lineWrapping: true,
        matchBrackets:true,
        mode:'text/html',
        extraKeys: {
          Enter: function(cm) {
            cm.replaceSelection("\n");
          }
        }
      });
var js_editor=CodeMirror.fromTextArea(dom("js"), {
        lineNumbers: true,
        mode: "javascript",
        lineWrapping: true,
        matchBrackets:true
      });
var css_editor=CodeMirror.fromTextArea(dom("css"), {
        lineNumbers: true,
        mode: "css",
        lineWrapping: true,
        matchBrackets:true
      });
html_editor.on("change", function(cm) {run1()});
js_editor.on("change", function(cm) {run1()});
css_editor.on("change", function(cm) {run1()});
window.addEventListener('message', ({data}) => {
//log处理
document.getElementById("log0").contentWindow.postMessage(data, '*');
  })
var code="var%20umaybesomeoneelsewillnotuseit%20%3D%200%3B%0A%0Afunction%20emaybesomeoneelsewillnotuseit(text)%20%7B%0A%20%20if%20(typeof%20text%20!%3D%3D%20'string')%20%7B%0A%20%20%20%20return%20String(text)%3B%0A%20%20%7D%0A%0A%20%20const%20escapeMap%20%3D%20%7B%0A%20%20%20%20'%26'%3A%20'%5C%26'%2C%0A%20%20%20%20'%3C'%3A%20'%26lt%3B'%2C%0A%20%20%20%20'%3E'%3A%20'%26gt%3B'%2C%0A%20%20%20%20'%22'%3A%20'%26quot%3B'%2C%0A%20%20%20%20%22'%22%3A%20'%26%2339%3B'%2C%0A%20%20%20%20'%2F'%3A%20'%26%23x2F%3B'%2C%0A%20%20%20%20'%20'%3A'%26nbsp%3B'%0A%20%20%7D%3B%0A%0A%20%20return%20text.replace(%2F%5B%26%3C%3E%22'%2F%20%5D%2Fg%2C%20match%20%3D%3E%20escapeMap%5Bmatch%5D)%0A%7D%0A%0Avar%20console%20%3D%20%7B%7D%3B%0A%0Aconsole.log%20%3D%20function%20(...args)%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20message%20%3D%20args.shift()%3B%0A%20%20const%20formattedMessage%20%3D%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20log%3A%20%24%7BformattedMessage%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0A%0Aconsole.error%20%3D%20function%20(...args)%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20message%20%3D%20args.shift()%3B%0A%20%20const%20formattedMessage%20%3D%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23FFD7D7%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20error%3A%20%24%7BformattedMessage%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0A%0Aconsole.warn%20%3D%20function%20(...args)%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20message%20%3D%20args.shift()%3B%0A%20%20const%20formattedMessage%20%3D%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23FFFCEA%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20warn%3A%20%24%7BformattedMessage%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0A%0Aconsole.info%20%3D%20function%20(...args)%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20message%20%3D%20args.shift()%3B%0A%20%20const%20formattedMessage%20%3D%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23CCE5FF%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20info%3A%20%24%7BformattedMessage%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0Aconsole.table%20%3D%20function(data)%20%7B%0Aumaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20let%20tableHTML%20%3D%20%60%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.table%3A%60%3B%0A%0A%20%20if%20(Array.isArray(data))%20%7B%0A%20%20%20%20if%20(data.length%20%3D%3D%3D%200)%20%7B%0A%20%20%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20table%3A%20(empty)%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%20%20%20%20return%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20if%20(Array.isArray(data%5B0%5D))%20%7B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctable%20style%3D%22border-collapse%3A%20collapse%3Bmargin-left%3A10px%22%3E%60%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Generate%20table%20header%0A%20%20%20%20%20%20const%20headerRow%20%3D%20data%5B0%5D.map((_%2C%20columnIndex)%20%3D%3E%20%60%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7BcolumnIndex%7D%3C%2Fth%3E%60).join('')%3B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%E7%B4%A2%E5%BC%95%3C%2Fth%3E%24%7BheaderRow%7D%3C%2Ftr%3E%60%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Generate%20table%20rows%0A%20%20%20%20%20%20data.forEach((row%2C%20rowIndex)%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20const%20rowData%20%3D%20row.map((cell%2C%20columnIndex)%20%3D%3E%20%60%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bcell%7D%3C%2Ftd%3E%60).join('')%3B%0A%20%20%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7BrowIndex%7D%3C%2Ftd%3E%24%7BrowData%7D%3C%2Ftr%3E%60%3B%0A%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20'%3C%2Ftable%3E%3C%2Fdiv%3E'%3B%0A%0A%20%20%20%20%20%20window.parent.postMessage('console_'%2BtableHTML%2C%20'*')%3B%0A%20%20%20%20%7D%20else%20if%20(typeof%20data%5B0%5D%20%3D%3D%3D%20'object'%20%26%26%20data%5B0%5D%20!%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctable%20style%3D%22border-collapse%3A%20collapse%3Bmargin-left%3A10px%22%3E%60%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Generate%20table%20header%0A%20%20%20%20%20%20const%20keys%20%3D%20Object.keys(data%5B0%5D)%3B%0A%20%20%20%20%20%20const%20headerRow%20%3D%20keys.map(key%20%3D%3E%20%60%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bkey%7D%3C%2Fth%3E%60).join('')%3B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%E7%B4%A2%E5%BC%95%3C%2Fth%3E%24%7BheaderRow%7D%3C%2Ftr%3E%60%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Generate%20table%20rows%0A%20%20%20%20%20%20data.forEach((obj%2C%20index)%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20const%20rowData%20%3D%20keys.map(key%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20%20%20const%20value%20%3D%20obj%5Bkey%5D%20%3D%3D%3D%20null%20%7C%7C%20obj%5Bkey%5D%20%3D%3D%3D%20undefined%20%3F%20''%20%3A%20obj%5Bkey%5D%3B%0A%20%20%20%20%20%20%20%20%20%20return%20%60%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bvalue%7D%3C%2Ftd%3E%60%3B%0A%20%20%20%20%20%20%20%20%7D).join('')%3B%0A%20%20%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bindex%7D%3C%2Ftd%3E%24%7BrowData%7D%3C%2Ftr%3E%60%3B%0A%20%20%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20'%3C%2Ftable%3E%3C%2Fdiv%3E'%3B%0A%0A%20%20%20%20%20%20window.parent.postMessage('console_'%2BtableHTML%2C%20'*')%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctable%20style%3D%22border-collapse%3A%20collapse%3Bmargin-left%3A10px%22%3E%60%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Generate%20table%20row%0A%20%20%20%20%20%20const%20rowData%20%3D%20data.map((value%2C%20index)%20%3D%3E%20%60%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bvalue%20%3D%3D%3D%20null%20%7C%7C%20value%20%3D%3D%3D%20undefined%20%3F%20''%20%3A%20value%7D%3C%2Ftd%3E%60).join('')%3B%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%E7%B4%A2%E5%BC%95%3C%2Fth%3E%24%7BrowData%7D%3C%2Ftr%3E%60%3B%0A%0A%20%20%20%20%20%20tableHTML%20%2B%3D%20'%3C%2Ftable%3E%3C%2Fdiv%3E'%3B%0A%0A%20%20%20%20%20%20window.parent.postMessage('console_'%2BtableHTML%2C%20'*')%3B%0A%20%20%20%20%7D%0A%20%20%7D%20else%20if%20(typeof%20data%20%3D%3D%3D%20'object'%20%26%26%20data%20!%3D%3D%20null)%20%7B%0A%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctable%20style%3D%22border-collapse%3A%20collapse%3Bmargin-left%3A10px%22%3E%60%3B%0A%0A%20%20%20%20%2F%2F%20Generate%20table%20header%0A%20%20%20%20const%20keys%20%3D%20Object.keys(data)%3B%0A%20%20%20%20const%20headerRow%20%3D%20keys.map(key%20%3D%3E%20%60%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bkey%7D%3C%2Fth%3E%60).join('')%3B%0A%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%E7%B4%A2%E5%BC%95%3C%2Fth%3E%24%7BheaderRow%7D%3C%2Ftr%3E%60%3B%0A%0A%20%20%20%20%2F%2F%20Generate%20table%20row%0A%20%20%20%20const%20rowData%20%3D%20keys.map(key%20%3D%3E%20%7B%0A%20%20%20%20%20%20const%20value%20%3D%20data%5Bkey%5D%20%3D%3D%3D%20null%20%7C%7C%20data%5Bkey%5D%20%3D%3D%3D%20undefined%20%3F%20''%20%3A%20data%5Bkey%5D%3B%0A%20%20%20%20%20%20return%20%60%3Ctd%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%24%7Bvalue%7D%3C%2Ftd%3E%60%3B%0A%20%20%20%20%7D).join('')%3B%0A%20%20%20%20tableHTML%20%2B%3D%20%60%3Ctr%20style%3D%22border%3A%201px%20solid%20black%3B%22%3E%3Cth%20style%3D%22border%3A%201px%20solid%20black%3B%20padding%3A%205px%3B%22%3E%E5%80%BC%3C%2Fth%3E%24%7BrowData%7D%3C%2Ftr%3E%60%3B%0A%0A%20%20%20%20tableHTML%20%2B%3D%20'%3C%2Ftable%3E%3C%2Fdiv%3E'%3B%0A%0A%20%20%20%20window.parent.postMessage('console_'%2BtableHTML%2C%20'*')%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20table%3A%20%24%7Bdata%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%7D%0A%7D%3B%0Aconsole.debug%20%3D%20function%20(...args)%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20message%20%3D%20args.shift()%3B%0A%20%20const%20formattedMessage%20%3D%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%2390c59c%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20debug%3A%20%24%7BformattedMessage%7D%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0A%0Aconsole.trace%20%3D%20function%20()%20%7B%0A%20%20umaybesomeoneelsewillnotuseit%2B%2B%3B%0A%20%20const%20error%20%3D%20new%20Error()%3B%0A%20%20const%20stackTrace%20%3D%20error.stack%3B%0A%20%20const%20escapedStackTrace%20%3D%20emaybesomeoneelsewillnotuseit(stackTrace)%3B%0A%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23F5F5F5%3Bdisplay%3A%20flex%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%20trace%3A%3Cpre%20style%3Dmargin-left%3A10px%3E%24%7BescapedStackTrace%7D%3C%2Fpre%3E%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%7D%3B%0Aconsole.clear%20%3D%20function()%7B%0Aumaybesomeoneelsewillnotuseit%3D0%0Awindow.parent.postMessage('console_console.clear'%2C%20'*')%3B%0Aumaybesomeoneelsewillnotuseit%2B%2B%0A%7D%0Awindow.consoleTimersmaybesomeoneelsewillnotuseit%20%3D%20%7B%7D%3B%0A%0Aconsole.time%20%3D%20function(timerName)%20%7B%0A%20%20if%20(window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D)%20%7B%0Aumaybesomeoneelsewillnotuseit%2B%2B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23FFFCEA%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.warn%3A%20Timer%20'%24%7BtimerName%7D'%20%E5%B7%B2%E5%AD%98%E5%9C%A8%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D%20%3D%20Date.now()%3B%0A%20%20%7D%0A%7D%3B%0A%0Aconsole.timeEnd%20%3D%20function(timerName)%20%7B%0Aumaybesomeoneelsewillnotuseit%2B%2B%0A%20%20if%20(window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D)%20%7B%0A%20%20%20%20const%20elapsedTime%20%3D%20Date.now()%20-%20window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D%3B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%24%7BtimerName%7D%3A%20%24%7BelapsedTime%7Dms%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%20%20delete%20window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23FFFCEA%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.warn%3A%20Timer%20'%24%7BtimerName%7D'%20%E4%B8%8D%E5%AD%98%E5%9C%A8%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%7D%0A%7D%3B%0A%0Aconsole.timeLog%20%3D%20function(timerName%2C%20...args)%20%7B%0Aumaybesomeoneelsewillnotuseit%2B%2B%0A%20%20if%20(window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D)%20%7B%0A%20%20%20%20const%20elapsedTime%20%3D%20Date.now()%20-%20window.consoleTimersmaybesomeoneelsewillnotuseit%5BtimerName%5D%3B%0A%20%20%20%20if%20(args.length%20%3E%200)%20%7B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%24%7BtimerName%7D%3A%20%24%7BelapsedTime%7Dms%20%60%2B'%20'%2Bargs.join('%20')%2C%20'*')%3B%0A%20%20%20%20%7Delse%7B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23E8E8E8%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.%24%7BtimerName%7D%3A%20%24%7BelapsedTime%7Dms%20%60%2C%20'*')%3B%0A%7D%0A%20%20%7D%20else%20%7B%0A%20%20%20%20window.parent.postMessage(%60console_%3Cdiv%20style%3D%22background%3A%23FFFCEA%3Bdisplay%3A%20flex%3Balign-items%3A%20center%3B%22%3E%24%7Bumaybesomeoneelsewillnotuseit%7D.warn%3A%20Timer%20'%24%7BtimerName%7D'%20%E4%B8%8D%E5%AD%98%E5%9C%A8%3C%2Fdiv%3E%60%2C%20'*')%3B%0A%20%20%7D%0A%7D%3B%0Afunction%20formatMessageMaybesomeoneelsewillnotuseit(message%2C%20...args)%20%7B%0A%20%20let%20index%20%3D%200%3B%0A%20%20message%3Demaybesomeoneelsewillnotuseit(String(message).replace(%2F%25%5BsdifoO%5D%2Fg%2C%20match%20%3D%3E%20%7B%0Aif(args.length%3E0)%7B%0A%20%20%20%20const%20arg%20%3D%20args.shift()%3B%0A%20%20%20%20switch%20(match)%20%7B%0A%20%20%20%20%20%20case%20'%25s'%3A%0A%20%20%20%20%20%20%20%20return%20String(arg)%3B%0A%20%20%20%20%20%20case%20'%25d'%3A%0A%20%20%20%20%20%20case%20'%25i'%3A%0A%20%20%20%20%20%20%20%20return%20parseInt(arg%2C%2010)%3B%0A%20%20%20%20%20%20case%20'%25f'%3A%0A%20%20%20%20%20%20%20%20return%20parseFloat(arg)%3B%0A%20%20%20%20%20%20case%20'%25O'%3A%0A%20%20%20%20%20%20%20%20return%20formatObjectMaybesomeoneelsewillnotuseit(arg)%3B%0A%20%20%20%20%20%20case%20'%25o'%3A%0A%20%20%20%20%20%20%20%20return%20formatExpandableObjectMaybesomeoneelsewillnotuseit(arg)%3B%0A%20%20%20%20%20%20default%3A%0A%20%20%20%20%20%20%20%20return%20match%3B%0A%20%20%20%20%7D%0A%7D%20else%20%7B%0Areturn%20match%3B%0A%7D%0A%20%20%7D))%3B%0Amessage%3DapplyStyleMaybesomeoneelsewillnotuseit(message%2C...args)%0A%0Areturn%20message.replace(%2F%5Cn%2Fg%2C%22%3Cbr%3E%22)%3B%0A%7D%0A%0Afunction%20formatObjectMaybesomeoneelsewillnotuseit(obj)%20%7B%0A%20%20if%20(typeof%20obj%20!%3D%3D%20'object'%20%7C%7C%20obj%20%3D%3D%3D%20null)%20%7B%0A%20%20%20%20return%20String(obj)%3B%0A%20%20%7D%0A%0A%20%20return%20JSON.stringify(obj)%3B%0A%7D%0A%0Afunction%20formatExpandableObjectMaybesomeoneelsewillnotuseit(obj)%20%7B%0A%20%20if%20(typeof%20obj%20!%3D%3D%20'object'%20%7C%7C%20obj%20%3D%3D%3D%20null)%20%7B%0A%20%20%20%20return%20String(obj)%3B%0A%20%20%7D%0A%0A%20%20const%20properties%20%3D%20Object.keys(obj)%3B%0A%20%20let%20formattedObject%20%3D%20''%3B%0A%0A%20%20for%20(let%20i%20%3D%200%3B%20i%20%3C%20properties.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20const%20prop%20%3D%20properties%5Bi%5D%3B%0A%20%20%20%20const%20value%20%3D%20formatObjectMaybesomeoneelsewillnotuseit(obj%5Bprop%5D)%3B%0A%20%20%20%20formattedObject%20%2B%3D%20%60%24%7Bprop%7D%3A%20%24%7Bvalue%7D%60%3B%0A%20%20%20%20if%20(i%20%3C%20properties.length%20-%201)%20%7B%0A%20%20%20%20%20%20formattedObject%20%2B%3D%20'%2C%20'%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20return%20%60%7B%20%24%7BformattedObject%7D%20%7D%60%3B%0A%7D%0Afunction%20applyStyleMaybesomeoneelsewillnotuseit(text%2C%20...styles)%20%7B%0Aconst%20styleRegex%20%3D%20%2F%25c%2Fg%3B%0Alet%20segments%20%3D%20String(text).split(styleRegex)%3B%0Alet%20stylesCopy%3D%20Array.from(styles)%3B%0Alet%20segmentsHead%3D%5B%5D%0Aif(segments.length%3Estyles.length%26%26%2F%25c%2F.test(text))%7B%0Alet%20segmentsCopy%3D%20Array.from(segments)%3B%0Afor(let%20i%3D0%3Bi%3Cstyles.length%3Bi%2B%2B)%7B%0AsegmentsHead.push(segmentsCopy.shift())%0A%7D%0Asegments%3DsegmentsHead.concat(segmentsCopy.join('%25c'))%0A%7D%0Alet%20styledText%20%3D%20''%3B%0Afor%20(let%20i%20%3D%200%3B%20i%20%3C%20segments.length%3B%20i%2B%2B)%20%7B%0A%20if%20(i%20%3C%3D%20styles.length%26%26i!%3D0)%20%7B%0A%20%20styledText%20%2B%3D%20%60%3Cspan%20style%3D%22%24%7BstylesCopy%5B0%5D.replace(%2F%5Cn%2Fg%2C'')%7D%22%3E%24%7Bemaybesomeoneelsewillnotuseit(segments%5Bi%5D)%7D%3C%2Fspan%3E%60%3B%0A%20%20stylesCopy.shift()%0A%20%7Delse%7B%20styledText%20%2B%3D%20emaybesomeoneelsewillnotuseit(segments%5Bi%5D)%3B%7D%0A%7D%0Aif%20(stylesCopy.length%20%3E%200)%20%7B%0A%20styledText%20%2B%3D%20'%26nbsp%3B'%2Bemaybesomeoneelsewillnotuseit(stylesCopy.join('%20'))%3B%0A%7D%0Areturn%20styledText%3B%0A%7D%0Awindow.onerror%20%3D%20function(msg%2Curl%2Cl)%0A%0A%7B%0Aumaybesomeoneelsewillnotuseit%2B%2B%0Avar%20txt%3D%22JavaScript%E8%BF%90%E8%A1%8C%E5%BC%82%E5%B8%B8%22%0A%0A%E3%80%80%E3%80%80%E3%80%80%E3%80%80txt%2B%3D%22%3Cbr%3EError%3A%20%22%20%2B%20msg%20%2B%20%22%3Cbr%3E%22%0A%0A%E3%80%80%E3%80%80%E3%80%80%E3%80%80txt%2B%3D%22URL%3A%20%22%20%2B%20url%20%2B%20%22%3Cbr%3E%22%0A%0A%E3%80%80%E3%80%80%E3%80%80%E3%80%80txt%2B%3D%22at%3A%3Cbr%3E%22%0A%0A%E3%80%80%E3%80%80%E3%80%80%E3%80%80txt%2B%3D((l-(******)-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length%3C%3D0)%3F%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%E6%9C%AA%E7%9F%A5%E9%94%99%E8%AF%AF%E5%AF%BC%E8%87%B4%E9%A2%84%E7%BD%AE%E8%84%9A%E6%9C%AC%E5%BC%82%E5%B8%B8%E6%88%96%E4%BA%8C%E6%AC%A1%E6%89%A7%E8%A1%8C%E8%84%9A%E6%9C%AC%E9%94%99%E8%AF%AF%22%3A((l-(******)-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length%3C%3DlocalStorage.readHTMLmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length)%3F(%22%3Cspan%20onclick%3D'window.parent.postMessage(%5C%22jumpToLine(html%2C%22%2B(l-(******)-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length)%2B%22)%5C%22%2C%5C%22*%5C%22)'%3E%26nbsp%3B%26nbsp%3B%26nbsp%3BHTML%E8%BE%93%E5%85%A5%E6%A1%86%26nbsp%3BLine%3A%22%2B(l-(******)-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length)%2B%22%3Cbr%3Ecode%3A%3Cspan%20style%3Dbackground%3Ayellow%3E%22%2Bemaybesomeoneelsewillnotuseit(localStorage.readHTMLmaybesomeoneelsewillnotuseit.split(%22%5Cn%22)%5Bl-(******)-1-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length%5D)%2B%22%3C%2Fspan%3E%3C%2Fspan%3E%22)%3A(%22%3Cspan%20onclick%3D'window.parent.postMessage(%5C%22jumpToLine(js%2C%22%2B(l-(******)-localStorage.readHTMLmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length)%2B%22)%5C%22%2C%5C%22*%5C%22)'%3E%26nbsp%3B%26nbsp%3B%26nbsp%3BJavaScript%E8%BE%93%E5%85%A5%E6%A1%86%26nbsp%3BLine%3A%22%2B(l-(******)-localStorage.readHTMLmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length)%2B%22%3Cbr%3E%22%2B%22code%3A%3Cspan%20style%3Dbackground%3Ayellow%3E%22%2Bemaybesomeoneelsewillnotuseit(localStorage.readJavaScriptmaybesomeoneelsewillnotuseit.split(%22%5Cn%22)%5Bl-(******)-1-localStorage.readHTMLmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length-localStorage.readCSSmaybesomeoneelsewillnotuseit.split(%22%5Cn%22).length%5D)%2B%22%3C%2Fspan%3E%3C%2Fspan%3E%3Cbr%3E%22)))%0Awindow.parent.postMessage((%22console_%3Cdiv%20style%3Dbackground%3A%23FFD7D7%3E%22%2Bumaybesomeoneelsewillnotuseit%2B%22.%20error%3A%22%2Btxt%2B%22%3C%2Fdiv%3E%22)%2C%20'*')%3B%0A%0Areturn%20true%0A%7D%20%0Aalert%3Dfunction()%7B%0Avar%20data%3B%0Aif(arguments.length%3D%3D0)%7Bdata%3D%22%22%7Delse%7Bdata%3DString(arguments%5B0%5D)%7D%0Aif(!confirm(%22%5Balert%5D%5Cn%E7%82%B9%E5%87%BB%E5%8F%96%E6%B6%88%E5%BC%BA%E5%88%B6%E5%81%9C%E6%AD%A2%E8%BF%90%E8%A1%8C%5Cn----------------%5Cn%22%2Bdata))%7B%0Awindow.parent.document.dispatchEvent(new%20CustomEvent('stopRunningEventmaybesomeoneelsewillnotuseit'))%0Athrow%20new%20Error(%22%E9%98%BB%E6%AD%A2%E7%BB%A7%E7%BB%ADalert%22)%0A%7D%0A%7D"
//result预置JS
code=code.replace(/\(\*\*\*\*\*\*\)/g,decodeURIComponent(code).split("\n").length)

//死循环保护
function addLoopProtection(code) {
  function createLoopCounterCheckermaybesomeoneelsewillnotuseit(loopIndex) {
    let confirmCounter = 0;
    let loopCounter = 0;
    let lastExecutionTime = Date.now();
    let allLoopCounter = 0;
    return function() {
      const currentTime = Date.now();
      const timeSinceLastExecution = currentTime - lastExecutionTime;
      var confirmText = `代码可能包含死循环，此循环已执行 ${allLoopCounter} 次，是否继续执行？`;
      if (loopCounter >= 100000 && confirmCounter <= 3 && timeSinceLastExecution >= 5000) {
        if (confirmCounter === 3) {
          confirmText += '本次之后将不会对此循环询问';
        }
        if (confirmCounter === 0 || confirm(confirmText)) {
          confirmCounter++;
          loopCounter = 0;
        } else {
          throw new Error('代码可能包含死循环，已终止执行。忽略此报错行号');
        }
          lastExecutionTime = currentTime;
      }

      loopCounter++;
      allLoopCounter++;
    };
  }

  let modifiedCode = code;
  modifiedCode = modifiedCode.replace(/<script(?:\s+type=['"]([\w\/]+)['"])?>(.*?)<\/script>/gs, (match, type, scriptContent) => {
var modifiedScriptContent=scriptContent;
var loopIndex=0;
    function flatten(arr) {
        return arr.reduce(function (flat, toFlatten) {
            return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
        }, []);
    }
    function insertStrings(originalString, insertions, positions) {
        // 将插入位置从小到大排序
        positions.sort(function (a, b) {
            return a - b;
        });

        // 初始化结果字符串为原始字符串
        let resultString = originalString;

        // 从后往前遍历插入位置和子字符串数组
        for (let i = positions.length - 1; i >= 0; i--) {
            const position = positions[i];
            const insertion = insertions[i];

            // 使用substring将插入字符串之前的部分提取出来
            const firstPart = resultString.substring(0, position);

            // 使用substring将插入字符串之后的部分提取出来
            const secondPart = resultString.substring(position);

            // 将所有部分连接起来，形成包含插入字符串的新字符串
            resultString = firstPart + insertion + secondPart;
        }

        return resultString;
    }

  function getLoopBodyRanges(code, loopType) {
    const ast = esprima.parseScript(code, {range: true});
    const loopBodyRanges = [];

    estraverse.traverse(ast, {
        enter: function (node, parent) {
            if (node.type === 'ForStatement' || node.type === 'WhileStatement' || node.type === 'DoWhileStatement') {
                if (node.body.type === loopType) {
                    const range = node.body.range;
                    loopBodyRanges.push(range);
                }
            }
        }
    });

    return loopBodyRanges;
}

    function processBlockStatement(code) {
        const startPositions = getLoopBodyRanges(code, "BlockStatement").map(x => x[0] + 1);
var insertions=[];
var i=-1;
while(i<startPositions.length-1)
      {
i++
loopIndex++;
insertions.push(`checkLoopIterationsIndex${loopIndex}maybesomeoneelsewillnotuseit();`)
      }
        return insertStrings(code, insertions, startPositions);
    }

    function processExpressionStatement(code) {
        const ranges = getLoopBodyRanges(code, "ExpressionStatement");
        let positions = flatten(ranges);
var insertions=[];
var i=-1;
while(i<positions.length-1)
      {
i++
loopIndex++;
insertions.push([`{checkLoopIterationsIndex${loopIndex}maybesomeoneelsewillnotuseit();`,"}"])
      }
insertions=flatten(insertions);
        return insertStrings(code, insertions, positions)
    }

    function processEmptyStatement(code) {
        const startPositions = getLoopBodyRanges(code, "EmptyStatement").map(x => x[0]);
var insertions=[];
var i=-1;
while(i<startPositions.length-1)
      {
i++
loopIndex++;
insertions.push(`{checkLoopIterationsIndex${loopIndex}maybesomeoneelsewillnotuseit();}`)
      }
        return insertStrings(code, insertions, startPositions)
    }

    function processCode(code) {
        code = processBlockStatement(code);
        code = processEmptyStatement(code);
        return processExpressionStatement(code);
    }


        try {
            modifiedScriptContent = processCode(scriptContent);
        } catch (e) {
        }
      const checkLoopIterations = [];
      for (let i = 1; i < loopIndex+1; i++) {
        checkLoopIterations.push(`var checkLoopIterationsIndex${i}maybesomeoneelsewillnotuseit = createLoopCounterCheckermaybesomeoneelsewillnotuseit(${i});`);
      }

      modifiedScriptContent = checkLoopIterations.join("") + modifiedScriptContent;
    

    const checkLoopProtection = createLoopCounterCheckermaybesomeoneelsewillnotuseit.toString().replace('function(index)', 'createLoopCounterCheckermaybesomeoneelsewillnotuseit').replace(/\n/g, '');

    return `<script${type ? ` type="${type}"` : ''}>${checkLoopProtection}${modifiedScriptContent}<\/script>`;
});
console.log('<!--死循环保护处理结果-->'+modifiedCode)
  return modifiedCode;
}


function run()
{
if(dom('cb_codemirror').checked){
var jsCode=js_editor.getValue()
var htmlCode=html_editor.getValue()
var cssCode=css_editor.getValue()
}else{
var jsCode=dom('js1').value
var htmlCode=dom('html1').value
var cssCode=dom('css1').value
}
localStorage.readJavaScriptmaybesomeoneelsewillnotuseit=jsCode
localStorage.readHTMLmaybesomeoneelsewillnotuseit=htmlCode
localStorage.readCSSmaybesomeoneelsewillnotuseit=cssCode
dom("log0").srcdoc=decodeURIComponent("%3Cscript%3E%0Awindow.addEventListener('message'%2C%20(%7Bdata%7D)%20%3D%3E%20%7B%0A%09if(%2F%5Econsole_%2F.test(data))%7B%0A%09%09data%3Ddata.replace(%2Fconsole_%2F%2C'')%0A%20%20if%20(data%20%3D%3D%3D%20'console.clear')%20%7B%0A%20%20%20%20document.body.innerHTML%20%3D%20'%3Cdiv%20style%3D%22display%3A%20flex%3B%22%3E1.%E5%B7%B2%E6%B8%85%E7%A9%BA%E6%8E%A7%E5%88%B6%E5%8F%B0%3C%2Fdiv%3E'%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20document.body.insertAdjacentHTML(%22beforeEnd%22%2C%20data)%3B%0A%20%20%7D%0A%7D%0A%7D)%3B%0A%3C%2Fscript%3E")
if(dom('cb_circle').checked){
var allCode=`<script>${decodeURIComponent(code)}<\/script>\n<style>${cssCode}<\/style>`+addLoopProtection(`\n${htmlCode}\n<script>${jsCode}<\/script>`)
}else{
var allCode=`<script>${decodeURIComponent(code)}<\/script>\n<style>${cssCode}<\/style>\n${htmlCode}\n<script>${jsCode}<\/script>`
}
dom("result").srcdoc=allCode
}

var run1=function()
{
try{clearTimeout(t);}catch(e){}
t=setTimeout(function(){
run()
},dom('time_input').value);
}
function i()
{
if(dom('cb_time').checked==false)
{
dom('time').innerHTML=''
run1=function(){}
}
else
{dom('time').innerHTML='&nbsp;&nbsp;防抖:<input id=time_input value=500 type=number>ms'
run1=function()
{
try{clearTimeout(t);}catch(e){}
t=setTimeout(function(){
run()
},dom('time_input').value);
}
}
}
function cm_click(){
if(!dom('cb_codemirror').checked){
var htmlCode=html_editor.getValue()
var jsCode=js_editor.getValue()
var cssCode=css_editor.getValue()
dom('codemirror_textarea').style.display='none'
dom('original_textarea').style.display='block'
dom('html1').value=htmlCode
dom('js1').value=jsCode
dom('css1').value=cssCode
}else{
var htmlCode=dom('html1').value
var jsCode=dom('js1').value
var cssCode=dom('css1').value
dom('original_textarea').style.display='none'
dom('codemirror_textarea').style.display='block'
html_editor.setValue(htmlCode)
js_editor.setValue(jsCode)
css_editor.setValue(cssCode)
}
}
//阻止alert后停止运行处理
window.document.addEventListener('stopRunningEventmaybesomeoneelsewillnotuseit', handleEvent, false)
function handleEvent(e) {
dom("result").srcdoc="";
dom("log0").srcdoc="";
var savedErudaPosition="";
if(localStorage["eruda-entry-button"]){
savedErudaPosition=localStorage["eruda-entry-button"]
}
localStorage.clear();
localStorage["eruda-entry-button"]=savedErudaPosition;
alert("已停止运行")
}
//跳转代码行号处理
function jumpToLine(type, lineNumber) {
if(dom('cb_codemirror').checked){
      const editor=eval(type+'_editor')
      editor.setCursor(lineNumber - 1, 0); // 设置光标到指定行的开头
      editor.setSelection({line: lineNumber - 1, ch: 0}, {line: lineNumber, ch: 0}); // 选中指定行
}
else{
 const textarea=dom(type+'1')
  const lines =textarea .value.split('\n');

  if (lineNumber > 0 && lineNumber <= lines.length) {
    const start = lines.slice(0, lineNumber -1).join('\n').length;
    const end = start + lines[lineNumber -1].length;

    textarea.setSelectionRange(start, end+1);
    textarea.focus();
  }
}
    }
 
window.addEventListener('message', ({data}) => {
  if (/^jumpToLine\([^,]+,\s*[^,]+\)$/.test(data)) {
    const regex = /jumpToLine\(([^,]+),\s*([^)]+)\)/;
    const matches = data.match(regex);
    if (matches) {
      const textarea = matches[1];
      const line = matches[2];
      if (textarea === 'js') {
        jumpToLine('js', line);
      } else {
        jumpToLine('html', line);
      }
    }
  }
});
</script>
<style>
#time_input{
width:100px;
border:solid 1px black;
border-left-style: none;
border-right-style: none;
border-top-style: none;
outline-style: none;
}
#time_input:hover{border:solid 2px #59E6B9;
border-left-style: none;
border-right-style: none;
border-top-style: none;
outline-style: none;}
</style>
</body>
</html>